package 代码记录.Bit48天集训;

import java.util.Arrays;
import java.util.Scanner;

/**选择题未搞定
 * 1.计算日期到天数转换(已搞定)
 * 2.幸运的袋子(已搞定)
 * @author zx
 * @create 2022-05-10 10:40
 */
public class day_14 {
    //自己做出来了
    public static void main3(String[] args){
        Scanner sc = new Scanner(System.in);
        int year = sc.nextInt();
        int month = sc.nextInt();
        int day = sc.nextInt();
        int res = 0;
        int[] arr = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        for(int i = 1;i < month;i++){
            if(i == 2 && isYear(year)){
                res++;
            }
            res += arr[i];
        }
        res += day;
        System.out.println(res);
    }
    private static boolean isYear(int y){
        if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) {
            return true;
        }else{
            return false;
        }
    }

    /**
     * @param args 比特数学方法,但是自己做不出来
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = scanner.nextInt();
            }
            Arrays.sort(arr);
            System.out.println(find(arr, 0, 0, 1));
        }
    }

    private static int find(int[] arr, int index, long sum, long multi) {
        int count = 0;
        for (int i = index; i < arr.length; i++) {
            sum += arr[i];
            multi *= arr[i];

            if (sum > multi) {
                count = count + 1 + find(arr, i + 1, sum, multi);
            } else if (arr[i] == 1) {
                //处理待判断的序列第一个数为1的时候，
                //那个1虽然不满足和大于积，但是要保留，继续往下考虑
                count = count + find(arr, i + 1, sum, multi);
            } else {
                break;
            }
            sum -= arr[i];//sum和multi在下一循环中还会用到
            multi /= arr[i];
            for (; i < arr.length - 1 && arr[i] == arr[i + 1]; i++) {
                //    i++;            //拥有相同号码的球是无区别的，因此跳过
            }
        }
        return count;
    }
}
